<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('牛奶出库列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<div class="btn-group " style="margin: 0px auto;display: table;" role="group">
					<button type="button" class="top-link btn btn-sm btn-white ">农事</button>
					<button type="button" class="top-link btn-sm  btn-white">牛奶入库</button>
					<button type="button" class="top-link btn-sm btn-white">牛奶仓储</button>
					<button type="button" class="top-link btn-sm  btn-primary">牛奶出库</button>
				</div>
			</div>

			<div class="btn-group-sm" id="toolbar" role="group">
				<!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:ncOutputMilk:add">
					<i class="fa fa-plus"></i> 添加
				</a>-->
				<a class="btn btn-warning" onclick="confirmTable();">
					<i class="fa fa-send"></i> 确认
				</a>
				<a class="btn btn-primary " onclick="openOrder();">
					<i class="fa fa-table"></i> 出库单管理
				</a>
				<div class="btn-group-sm" id="toolbar1" role="group">
					<h3 class="inline">当天工作内容：</h3>

				</div>

			</div>

			<div class="col-sm-12 select-table table-striped ">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>


			<div class="col-sm-12 select-table table-striped">
				<h3>出库订单表：</h3>
				<table id="bootstrap-table-1" data-mobile-responsive="true"></table>
			</div>
		</div>
		 <div class="bottom-btns"></div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
		// var editFlag = [[${@permission.hasPermi('system:ncOrderCf:edit')}]];
		/*var removeFlag = [[${@permission.hasPermi('system:ncOrderCf:remove')}]];
		var editFlag1 = [[${@permission.hasPermi('system:ncOutputMilk:edit')}]];
		var removeFlag1 = [[${@permission.hasPermi('system:ncOutputMilk:remove')}]];*/

		var prefix = ctx + "system/ncOrderCf";
		var datas = [[${@dict.getType('cforderType')}]];
		var cforderStatus = [[${@dict.getType('cforderStatus')}]];
		var normal_unit = [[${@dict.getType('normal_unit')}]];
		$(function () {
			var options = {
				url: prefix + "/list?status=2&cforderStatus=6",
				createUrl: prefix + "/add",
				updateUrl: prefix + "/edit/{id}",
				removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
				modalName: "牛奶出库",
				showExport: true,
				toolbar: 'toolbar1',

				columns: [
						/*{
					checkbox: true
				},*/
					{
						title: '序号',
						formatter: function (value, row, index) {
							return $.table.serialNumber(index);
						}
					},
					{
						field: 'cforderCode',
						title: '订单编号',
						sortable: true
					},
					{
						field: 'cropNameCn',
						title: '作物名称',
						sortable: true
					},
					/*{
						field: 'cropVarietiesCn',
						title: '作物品种',
						sortable: true
					},*/
					/*{
						field: 'createTime',
						title: '创建时间',
						sortable: true
					},
					{
						field: 'requestTime',
						title: '需求日期',
						formatter: function (value, row, index) {
							return dateFtt(value);
						}
					},
					{
						field: 'cforderId',
						title: '菜房订单键',
						visible: false
					},*/
					{
						field: 'cforderType',
						title: '出库类型',
						formatter: function (value, row, index) {
							return $.table.selectDictLabel(datas, value);
						}
					},

					{
						field: 'requestAmount',
						title: '需求数量',
						sortable: true
					},
					{
						field : 'outputAmout',
						title : '实际提供数量（kg）',
					},
					/*{
						field: 'unit',
						title: '单位',
						formatter: function (value, row, index) {
							return $.table.selectDictLabel(normal_unit, value);
						}
					},

					{
						field: 'cforderStatus',
						title: '状态',
						sortable: false,
						formatter: function (value, row, index) {
							/!*蔬菜类状态：1、待分配，2、待检测，3、待入库，4、待出库，5、已完成
                            牛奶鸡蛋：6、牛舍待确认，7、鸡舍待确认，8、牛舍已确认，9、鸡舍已确认*!/
							return $.table.selectDictLabel(cforderStatus, value);
						}
					},
					{
						field: 'distribution',
						title: '分配情况',
						sortable: false,
						formatter: function (value, row, index) {
							if (1 == value) {
								return "检测"
							}
							if (2 == value) {
								return "仓储"
							}
							return "--";
						}
					}, */{
						field: 'remark',
						title: '备注'
					},
					{
						title: '操作',
						align: 'center',
						formatter: function (value, row, index) {
							var actions = [];
							/*actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.cforderId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
							actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.cforderId + '\')"><i class="fa fa-remove"></i>删除</a>');*/
							actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)"  onclick="enter(\'' + row.cforderId + '\')"><i class="fa fa-edit"></i>确认</a> ');
							return actions.join('');
						}
					}]
			};
			$.table.init(options);
			var options1 = {
				url: ctx+'system/ncOutputMilk' + "/list?outputType=2",
				createUrl: prefix + "/add",
				updateUrl: ctx+'system/ncOutputMilk'+ "/edit/{id}",
				removeUrl: ctx+'system/ncOutputMilk' + "/remove",
				exportUrl: prefix + "/export",
				id:'bootstrap-table-1',
				modalName: "牛奶出库",
				showExport: true,
				sortName:'outputTime',
				sortOrder:'desc',
				columns: [
						/*{
					checkbox: true
				},
					{
						field : 'outputId',
						title : '序号',
					},*/
					{
						title: '序号',
						formatter: function (value, row, index) {
							return $.table.serialNumber(index);
						}
					},
					/*{
						field : 'inputId',
						title : '批次',
						sortable: true
					},*/
					/*{
						field : 'cforderId',
						title : '菜房订单id',
						sortable: true
					},*/
					{
						field : 'cforderCode',
						title : '牛奶批次',
					},
					{
						field : 'cropNameCn',
						title : '产品名称',
					},
					/*{
						field : 'cropVarietiesCn',
						title : '产品种类',
					},*/
					{
						field : 'requestAmount',
						title : '需求数量（kg）',
						sortable: true
					},
					{
						field : 'outputAmout',
						title : '实际提供数量（kg）',
					},
					{
						field: 'milkmanName',
						title: '挤奶人员'
					},
					{
						field: 'disinfectorName',
						title: '消毒人员'
					},
					/*{
						field : 'bottleAmount',
						title : '瓶数',
						sortable: true
					},*/
					{
						field: 'cforderType',
						title: '出库类型',
						formatter: function (value, row, index) {
							return $.table.selectDictLabel(datas, value);
						}
					},
					{
						field : 'outputTime',
						title : '出库时间',
						sortable: true
					},
					/*{
						field : 'outputType',
						title : '出库类型 ：字典',
						sortable: true
					},*/
					{
						field : 'outputUserName',
						title : '出库经手人'
					},
					/*{
						field : 'createBy',
						title : '创建者',
						sortable: true
					},
					{
						field : 'createTime',
						title : '创建时间',
						sortable: true
					},*/
					{
						field : 'remark',
						title : '备注',
						sortable: true,
                        formatter: function (value, row, index) {
                            return $.table.tooltip(value);
                        }
					},
					{
						title: '操作',
						align: 'center',
						formatter: function(value, row, index) {
							var actions = [];
							actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.outputId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
							actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.outputId + '\')"><i class="fa fa-remove"></i>删除</a>');
							return actions.join('');
						}
					}]
			};
			$.table.init(options1);

			var btns = [
				{
					name: "产奶记录",
					url: ctx + 'system/ncCowsMilk',
					id: 'Milk-work'
				},
				{
					name: "主饲料",
					url: ctx + 'system/ncFeed?feedType=1',
					id: 'Feed-work'
				},
				{
					name: "辅饲料",
					url: ctx + 'system/ncFeed2?feedType=2',
					id: 'Feed2-work'
				},
				{
					name: "消毒记录",
					url: ctx + 'system/ncCowsDisinfection?managerType=2',
					id: 'Disinfection-work'
				},
				{
					name: "兽医请求",
					url: ctx + 'system/ncZhenliaoLogs/cow/askZhenLiaoList ',
					id: 'Zhenliao-work'
				},
				{
					name: "所有诊疗记录",
					url: ctx + 'system/ncZhenliaoLogs/cow/allZhenliao   ',
					id: 'Zhenliao-all'
				},
				{
					name: "诊疗单",
					url: ctx + 'system/ncOrder?orderType=14',
					id: 'Medical-work'
				},
				{
					name: "档案管理",
					url: ctx + 'system/ncCowsFiles',
					id: 'Depot-work'
				},
				{
					name: '工作记录',
					url: ctx + 'system/ncNormalWorks?workType=8',
					id: 'normal-work'
				},
                {
                    name: '所有出库',
                    url: ctx + 'system/ncOutputMilk/ncOutputMilkAll',
                    id: 'ncOutputMilkAll'
                }

			]
			addBtns(btns);


        });

		/*牛奶入库*/
		$('.top-link').click(function () {
			var index = $(this).index();
			switch (index) {
				case 0:
					window.location.href = ctx + 'system/ncWorkNotice';
					return;
				case 1:
					window.location.href = ctx +'system/ncInputMilk';

					return;
				case 2:
					window.location.href = ctx +'system/ncInputMilkStorage';
					return;
				case 3:
					$.table.refresh();
					return;
			}
		})

		function enter(id){

			var url = 'ncOutputMilk' + '/enter/'+id;
			$.modal.open("出库记录单", url);
		}

		/*表单确认*/
		function confirmTable() {
			var confirmTable = ctx+'system/ncOutputMilk' + "/confirmTable";
			var data = $('#bootstrap-table-1').bootstrapTable('getData');
			console.log(data)
			if (data && data.length > 0) {

				$.modal.confirm("确认生成订单吗？", function () {
					var ids = [];
					$(data).each(function (i, e) {
						ids.push(e.outputId);
					});
					var ids_str = ids.join(",");
					myPost(confirmTable, {ids: ids_str},
							function (data) {

								if (data.code == 0) {
									layer.msg("提交成功")
								} else {
									layer.msg(data.msg);
								}
								$.table.refresh()
							}, function (e) {
								layer.msg("确认失败!");
								$.table.refresh()
							})

				})
			} else {
				layer.msg("未发现数据!")
			}

		}
		/*打开检测记录单*/
		function openOrder() {

			var url = ctx + 'system/ncOrder?orderType=11 ';

			$.modal.openTab("出库单管理", url);
		}
        setTitle("牛舍管理-牛奶出库",false)

    </script>
</body>
</html>